/*
 * Copyright 2012 ITC Tsinghua University. All Rights Reserved.
 */
package cn.edu.tsinghua.cic.ccss.qo;

import org.forten.core.dao.rdb.hibernate.QueryInfo;
import org.forten.core.qo.QueryEntity;
import org.forten.core.qo.QueryObject;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import cn.edu.tsinghua.cic.ccss.entity.Course;

/**
 * 
 * 
 * @author <a href="mailto:du_yi@bbn.cn">Duyi</a>
 * 
 * @since 2012-5-15
 */
@QueryEntity(Course.class)
@Component("courseQo4Selection")
@Scope("prototype")
public class CourseQo4Selection implements QueryObject {
	private String name;
	private String teacherName;
	private String start;
	private String end;
	
	
	public String getStart() {
		return start;
	}

	public void setStart(String start) {
		this.start = start;
	}

	public String getEnd() {
		return end;
	}

	public void setEnd(String end) {
		this.end = end;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getTeacherName() {
		return teacherName;
	}

	public void setTeacherName(String teacherName) {
		this.teacherName = teacherName;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.forten.core.qo.QueryObject#beforeBuildQueryInfo()
	 */
	@Override
	public void beforeBuildQueryInfo() {

	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.forten.core.qo.QueryObject#afterBuildQueryInfo(org.forten.core.dao
	 * .rdb.hibernate.QueryInfo)
	 */
	@Override
	public QueryInfo afterBuildQueryInfo(QueryInfo qi) {
		// Date currentTime = DateUtil.currentTime();
		// Expression leBegin = Compare.lt("startTimeChoose",
		// Param.getCommonParam("begin", currentTime, Type.DATE));
		// Expression geEnd = Compare.gt("endTimeChoose",
		// Param.getCommonParam("end", currentTime, Type.DATE));
		// qi.addExpressionsToWhere(leBegin, geEnd);
		// qi.setOrderby(OrderBy.getOrderBy(Order.desc("teachTime")));
		return qi;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.forten.core.qo.QueryObject#clean()
	 */
	@Override
	public void clean() {
		teacherName = null;
		name = null;
		start = null;
		end = null;
	}

	@Override
	public String toString() {
		return "CourseQo4Selection [name=" + name + ", teacherName="
				+ teacherName + ", start=" + start + ", end=" + end + "]";
	}

	
}
